package com.xjrsoft.module.customerTwo.barin.t_barin_srerp_list.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_list.entity.TBarinSrerpList;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.core.tool.utils.CollectionUtil;
import java.util.ArrayList;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_list.dto.TBarinSrerpListListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_list.mapper.TBarinSrerpListMapper;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_list.service.ITBarinSrerpListService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2024-06-18
 */
@Service
@AllArgsConstructor
public class TBarinSrerpListServiceImpl extends BaseService<TBarinSrerpListMapper, TBarinSrerpList> implements ITBarinSrerpListService {


	@Override
	public IPage<TBarinSrerpList> getPageList(TBarinSrerpListListDto pageListDto) {
		Wrapper<TBarinSrerpList> wrapper = Wrappers.<TBarinSrerpList>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getF_FirmName()), TBarinSrerpList::getFFirmname, pageListDto.getF_FirmName())
				.like(!StringUtil.isEmpty(pageListDto.getF_Account()), TBarinSrerpList::getFAccount, pageListDto.getF_Account());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public String addTBarinSrerpList(TBarinSrerpList tBarinSrerpList) {
		String tBarinSrerpListId = IdWorker.get32UUID();
		tBarinSrerpList.setFId(tBarinSrerpListId);
		boolean isSuccess = this.save(tBarinSrerpList);
		return isSuccess ? tBarinSrerpListId : null;
	}

	@Override
	public boolean updateTBarinSrerpList(String id, TBarinSrerpList tBarinSrerpList) {
		tBarinSrerpList.setFId(id);
		return this.updateById(tBarinSrerpList);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

	@Override
	public int addSrerpData() {
		return this.getBaseMapper().addSrerpData();
	}

}